#include <stdio.h>
#include <string.h>

int MaxSubArraySum(int *str, int length)
{
    int max = str[0];
    for (int idx = 0; idx < length; idx++)
    {
        int num = 0;
        for (int ide = 0 + idx; ide < length; ide++)
        {
            num += str[ide];
            if (num > max)
            {
                max = num;
            }
        }
    }
    return max;
}
int main()
{
    int arr[10] = {-2, 1, -3, 4, -1, 2, 1, -5, 4};
    int length = sizeof(arr) / sizeof(arr[0]);
    int max = MaxSubArraySum(arr, length);
    printf("%d\n", max);
    return 0;
}